<template>
  <div>
    <!-- <el-form ref="form" :model="form" label-width="120px" style="width: 50%">
      <el-form-item label="保存至文件夹">
        <input
          type="file"
          id="file"
          hidden
          @change="fileChange"
          webkitdirectory
        />
        <el-input
          placeholder="请输入内容"
          v-model="form.imgSavePath"
          class="input-with-select"
        >
          <el-button
            slot="append"
            icon="el-icon-folder"
            type="success"
            @click="btnChange"
          ></el-button>
        </el-input>
      </el-form-item>
    </el-form> -->
    <input id="path" type="text" name="path" size="30" />
    <input type="button" value="选择" @click="browseFolder('path')" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        imgSavePath: "",
      },
    };
  },
  methods: {
    browseFolder(path) {
      try {
        var Message = "\u8bf7\u9009\u62e9\u6587\u4ef6\u5939"; //选择框提示信息
        var Shell = new ActiveXObject("Shell.Application");
        var Folder = Shell.BrowseForFolder(0, Message, 64, 17); //起始目录为：我的电脑
        //var Folder = Shell.BrowseForFolder(0, Message, 0); //起始目录为：桌面
        if (Folder != null) {
          Folder = Folder.items(); // 返回 FolderItems 对象
          Folder = Folder.item(); // 返回 Folderitem 对象
          Folder = Folder.Path; // 返回路径
          if (Folder.charAt(Folder.length - 1) != "\\") {
            Folder = Folder + "\\";
          }
          document.getElementById(path).value = Folder;
          return Folder;
        }
      } catch (e) {
        alert(e.message);
      }
    },
    fileChange(e) {},
    btnChange() {
      var file = document.getElementById("file");
      file.click();
    },
  },
};
</script>

<style>
</style>